package org.example.softwarearchitecture.controller;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.example.softwarearchitecture.exception.XException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.util.Map;


@RestControllerAdvice
@Slf4j
public class ExceptionController {

    @ExceptionHandler(XException.class)
    public Map<String, Object> handleException(XException e) {
        return Map.of("message", e.getMessage());
    }
}
